package com.ems.remote;

import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 监听EMS的挂载
 * @Author: Wuzh
 * @Description:
 * @Date Created in 23:26 2023-12-28
 * @return
 */
@Component
public class NettyListener implements ApplicationListener<ContextRefreshedEvent> {

    @Resource
    private NettyTcpServer nettyTcpServer;

    @Override
    public void onApplicationEvent (ContextRefreshedEvent contextRefreshedEvent) {
        if ( contextRefreshedEvent.getApplicationContext ().getParent () == null ) {
            try {
                nettyTcpServer.start ();
            } catch ( Exception e ) {
                e.printStackTrace ();
            }
        }
    }
}
